package com.rest.response;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2018/5/31.
 */

public class Patient implements Serializable {
    public String periodid;
    public String patientSex;
    public String initiatorDocId;
    public String initiatorHosId;
    public String initiatorDocName;
    public String patientBirth;
    public String initiatorHosName;
    public String initialHosAndDocNames;
    public String receiveHosAndDocNames;
    public int flag;
    public String hint;

    public String reason;
    public String patientName;
    public String eyePressureRight;
    public String bookDate;
    public String medhisId;
    public String preDiagnose;
    public String diagnoseId;
    public String patientId;
    public String nakedEyesightRight;
    public String patientIdcard;
    public String patientPhone;
    public String eyePressureLeft;
    public String diagnoseAdvice;
    public String medhisGms;
    public String medhisZs;
    public String medhisXbs;
    public String patientAddr;
    public String medhisJws;
    public String curedEyesightRight;
    public String nakedEyesightLeft;
    public String createDate;
    public String curedEyesightLeft;

    public String age;
    public String sex;
    public String diagnoseName;
    public String updateTime;
    public String phone;
    public String addr;
    public String createTime;
    public String id;
    public String groupName;
    public String tbPatientId;

    public String getHint() {
        switch (flag) {
            case 0:
                return "申请失败";
            case 1:
                return "未反馈";
            case 2:
                return "申请成功";
            case 3:
                return "已反馈";
            case 4:
                return "待确认时间";
            case 5:
                return "未发起";
            default:
                return "";

        }
    }

    public String getAge() {
        if (patientBirth == null) {
            return "0";
        }
        int age = 0;
        try {
            Calendar calendar = Calendar.getInstance();
            int timeNow = calendar.get(Calendar.YEAR);
            Date date = new SimpleDateFormat("yyyy-MM-dd").parse(patientBirth);
            calendar.setTime(date);
            age = timeNow - calendar.get(Calendar.YEAR);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return age + "";
    }


}
